#include "Emitter.h"

Emitter::Emitter()
{
	m_fFrequency = EMITTER_DEFAULT_FREQUENCY;
	m_bOn =	EMITTER_DEFAULT_ON;
	m_fTimeToNextEmission = EMITTER_DEFAULT_TIMETONEXTEMISSION;
}

Emitter::~Emitter()
{
}

void Emitter::Update(float elapsedTime)
{
	if(m_bOn)
	{
		m_fTimeToNextEmission -= elapsedTime;

		if(m_fTimeToNextEmission <= 0.0f)
		{
			Emit();

			m_fTimeToNextEmission = 1.0f / m_fFrequency;
		}
	}
}

const float Emitter::GetFrequency() const
{
	return m_fFrequency;
}

const bool Emitter::IsOn() const
{
	return m_bOn;
}

void Emitter::SetFrequency(float frequency)
{
	m_fFrequency = frequency;
}

void Emitter::SetOn(bool on)
{
	m_bOn = on;
}